package com.jwsoft.manager.core.gateway.controller;

import com.bifang.assistant.common.constants.Validators;
import com.bifang.engine.assistant.core.domain.AppResponse;
import com.bifang.engine.protect.core.annotation.Idempotent;
import com.github.pagehelper.PageInfo;
import com.jwsoft.manager.common.vo.eduSchoolTj.*;
import com.jwsoft.manager.common.vo.eduStudentEnroll.EduStudentEnrollKeyVO;
import com.jwsoft.manager.common.vo.eduStudentEnroll.MyTjSchoolVO;
import com.jwsoft.manager.core.integration.EduSchoolTjIntegration;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 学校调剂人数表网关
 *
 * @author wangtao
 * @since 2022-12-20
 */
@RestController
@RequestMapping(value = "/doc/api")
@Tag(name = "学校调剂人数表", description = "学校调剂人数表")
public class EduSchoolTjController {

    @Autowired
    public EduSchoolTjIntegration eduSchoolTjIntegration;

    @Operation(summary = "学校调剂人数表分页查询",description = "学校调剂人数表分页查询")
    @PostMapping(value = "/eduSchoolTj0001", produces = "application/json;charset=UTF-8")
    public AppResponse<PageInfo<EduSchoolTjVO>> getList(@RequestBody @Validated EduSchoolTjQueryVO vo) {
        return AppResponse.successData(eduSchoolTjIntegration.getList(vo));
    }

    @Operation(summary = "学校调剂人数表根据主键查询详情",description = "学校调剂人数表根据主键查询详情")
    @PostMapping(value = "/eduSchoolTj0002", produces = "application/json;charset=UTF-8")
    public AppResponse<EduSchoolTjVO> getById(@RequestBody @Validated EduSchoolTjKeyVO vo) {
        return AppResponse.successData(eduSchoolTjIntegration.getById(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "学校调剂人数表新增",description = "学校调剂人数表新增")
    @PostMapping(value = "/eduSchoolTj0004", produces = "application/json;charset=UTF-8")
    public AppResponse<EduSchoolTjVO> add(@RequestBody @Validated(value = {Validators.Add.class}) EduSchoolTjVO vo) {
        return AppResponse.successData(eduSchoolTjIntegration.add(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "学校调剂人数表修改",description = "学校调剂人数表修改")
    @PostMapping(value = "/eduSchoolTj0005", produces = "application/json;charset=UTF-8")
    public AppResponse<EduSchoolTjVO> edit(@RequestBody @Validated(value = {Validators.Edit.class}) EduSchoolTjVO vo) {
        return AppResponse.successData(eduSchoolTjIntegration.edit(vo));
    }

    @Idempotent(expire="PT2S") //2秒内防重复提交
    @Operation(summary = "学校调剂人数表删除",description = "学校调剂人数表删除")
    @PostMapping(value = "/eduSchoolTj0006", produces = "application/json;charset=UTF-8")
    public AppResponse del(@RequestBody @Validated EduSchoolTjKeyVO vo) {
        eduSchoolTjIntegration.del(vo);
        return AppResponse.successMsg("删除成功！");
    }


    @Operation(summary = "根据报名id查询可调剂学校", description = "根据报名id查询可调剂学校")
    @PostMapping(value = "/eduSchoolTj0009", produces = "application/json;charset=UTF-8")
    public AppResponse<List<MyTjSchoolVO>> getList(@RequestBody @Validated EduStudentEnrollKeyVO vo) {
        return AppResponse.successData(eduSchoolTjIntegration.getByEnrollStudentId(vo));
    }

}
